//
//  YZClient+FreeExperience.m
//  YZMicroStock
//
//  Created by apple on 2017/10/31.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZNetworkManager.h"

@implementation YZNetworkManager (FreeExperience)


- (void)freeEx_getConfigureDataSuccess:(void (^)(NSURLResponse *response,id responseObject))success failure: (void (^)(NSError *error))failure{
    [self.mainNetwork cq_noCachePOST:URL_FOR_FETCH_FREEEXPERIENCE_CONFIGURE_DATA parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

- (void)freeEx_createStrategyWithParams:(NSMutableDictionary *)dic success:(void (^)(NSURLSessionDataTask *task,id responseObject))success failure: (void (^)(NSError *error))failure {
    
    NSDictionary *params = @{@"holdNum":dic[@"amount"],
                             @"stockCode":dic[@"stockCode"],
                             @"token":dic[@"token"],
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_CREATE_FREEEXPERIENCE_STRATERY parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

- (void)freeEx_getSaleListFirstWithParamsuccess:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_FIRST_FETCH_SALELIST_ABOUT_FREEEXPERIENCE parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}


- (void)freeEx_getSettleListWithParamsuccess:(void (^)(NSURLSessionDataTask *task,id responseObject))success failure: (void (^)(NSError *error))failure{
    NSDictionary *params = @{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_FETCH_SETTLELIST_ABOUT_FREEEXPERIENCE parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}


- (void)freeEx_closeTradeWithID:(long long)tid  success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{@"strategyId":@(tid),
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    [self.mainNetwork cq_noCachePOST:URL_FOR_SALE_STRATEGY_ABOUT_FREEEXPERIENCE parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}



@end
